Skip to content

feat: implement addItemToReturnArray method#69

Open
artengin wants to merge 7 commits into
masterfrom
create-add-item-to-return-array
Open

feat: implement addItemToReturnArray method#69
artengin wants to merge 7 commits into
masterfrom
create-add-item-to-return-array

Conversation

@artengin

@artengin artengin commented May 12, 2026

Copy link
Copy Markdown
Contributor

refs: #71

@artengin

Copy link
Copy Markdown
Contributor Author

It inherits from this commit: #64

@artengin artengin self-assigned this May 12, 2026
@coveralls

coveralls commented May 12, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27291937801

Coverage increased (+0.2%) to 98.853%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 64 of 64 lines across 8 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 436
Covered Lines: 431
Line Coverage: 98.85%
Coverage Strength: 10.35 hits per line

💛 - Coveralls

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3b724c1f4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Visitors/MethodVisitors/AddMethod.php
@artengin artengin force-pushed the create-add-item-to-return-array branch from b3b724c to 2d7ffe6 Compare June 8, 2026 06:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d7ffe63e6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Nodes/PreformattedExpression.php Outdated
Comment thread src/Visitors/MethodVisitors/AddItemToReturnArray.php
@artengin

artengin commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fadeec638

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Nodes/PreformattedExpression.php Outdated
protected function parsePHPCode(string $code): array
{
try {
$stmts = new ParserFactory()->createForHostVersion()->parse("<?php\n{$code};");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject statements before embedding array values

When addItemToReturnArray() is called with syntactically valid PHP that is not a single expression, such as return 1 or $a = 1; $b = 2, this parser accepts it here and PreformattedExpression later prints the raw text inside an array item. That produces invalid generated PHP like return [return 1,]; instead of throwing InvalidPHPCodeException, so callers can corrupt the target file with an input that passed validation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validate PHP syntax only. Semantic correctness of the value is the caller's responsibility, like elsewhere in this library.

@artengin artengin force-pushed the create-add-item-to-return-array branch from 3fadeec to cf924f2 Compare June 10, 2026 12:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf924f2562

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Nodes/PreformattedExpression.php Outdated
@artengin

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

$returnNodes = new NodeFinder()->findInstanceOf($node->stmts ?? [], Return_::class);

P2 Badge Ignore nested returns when locating the method return

When the target method contains a closure or anonymous function before its own returned array, NodeFinder::findInstanceOf() recursively counts that nested return as part of the method, so a valid method like one building a callback and then return [...] will throw MultipleReturnStatementsException instead of updating the array. The search should skip nested function/class scopes or otherwise identify only returns that belong to the target method body.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@artengin

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca7af3fd92

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

protected function validatePHPCode(string $code): void
{
try {
new ParserFactory()->createForHostVersion()->parse("<?php\n{$code}?>");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject statements before embedding expressions

When $value or $key is a syntactically valid PHP statement but not an expression (for example return 1; or if ($x) {}), this validation succeeds because it parses the snippet as a whole PHP file. The same raw text is then printed inside an array item expression by AddItemToReturnArray, producing an invalid PHP file instead of throwing InvalidPHPCodeException; validate these snippets specifically as expressions before accepting them.

Useful? React with 👍 / 👎.

@artengin artengin assigned DenTray and unassigned artengin Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants